/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package cz.muni.fi.pa165.machineryrental.converters;

import cz.muni.fi.pa165.machineryrental.dto.RevisionDTO;
import cz.muni.fi.pa165.machineryrental.entities.Revision;

/**
 *
 * @author Marian Lorenc, 374122
 */
public class RevisionDTOConverter {
    /**
     * Converts Revision entity to RevisionDTO
     * @param entity
     * @return RevisionDTO which is set by Revision entity 
     */
    public static RevisionDTO toDTO(Revision entity) {
        if (entity == null) {
            throw new IllegalArgumentException("Entity can't be null.");
        }

        RevisionDTO dto = new RevisionDTO();

        dto.setId(entity.getId());
        dto.setDateOfRevision(entity.getDateOfRevision());
        dto.setDescription(entity.getDescription());
        
        return dto;
    }

    /**
     * Converts RevisionDTO to Revision entity
     * @param dto
     * @return Revision entity which is set by RevisionDTO
     */
    public static Revision toEntity(RevisionDTO dto) {
        if (dto == null) {
            throw new IllegalArgumentException("dto can't be null.");
        }

        Revision entity = new Revision();
        entity.setId(dto.getId());
        entity.setDateOfRevision(dto.getDateOfRevision());
        entity.setDescription(dto.getDescription());

        return entity;
    }

}
